//
//  TGAdvertCollectionReusableView.m
//  WanCaiC8
//
//  Created by QiuXun on 2019/1/21.
//  Copyright © 2019 tangang. All rights reserved.
//

#import "TGAdvertCollectionReusableView.h"
#import "AdvertisingView.h"



@interface TGAdvertCollectionReusableView()
@property(nonatomic,strong)AdvertisingView *oneAdvertisingView;


@end
@implementation TGAdvertCollectionReusableView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

-(void)setupUI{
    
    [self.oneAdvertisingView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(5);
        make.left.equalTo(self).offset(10);
        make.right.equalTo(self).offset(-10);
        make.height.mas_equalTo(@0);
    }];
    
    
}

- (AdvertisingView *)oneAdvertisingView{
    if (!_oneAdvertisingView) {
        WS(weakSelf);
        _oneAdvertisingView =[[AdvertisingView alloc]init];
        [self addSubview:_oneAdvertisingView];
        self.oneAdvertisingView.changeHeight = ^(float height) {
            [weakSelf.oneAdvertisingView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.height.mas_equalTo(@(height));
            }];
        };
    }
    return _oneAdvertisingView;
}

-(void)setAdModelArr:(NSMutableArray *)adModelArr AndRowCount:(NSInteger)rowCount{
      _adModelArr = adModelArr;
    if (adModelArr.count>0) {
        self.oneAdvertisingView.dataArr = adModelArr;
        
        self.oneAdvertisingView.changeHeight(rowCount*40);
    
    }
     
}

@end
